import Vue, { DirectiveOptions } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import 'normalize.css'
import './styles/index.scss'
import * as directives from './directives'
// import * as filters from './filters'
import { globalErrorHandler } from './utils'

import ElementUI from 'element-ui'
if (process.env.NODE_ENV !== 'production') {
  require('element-ui/lib/theme-chalk/index.css')
}

Vue.use(ElementUI, { size: 'small' })

// Register global directives
Object.keys(directives).forEach(key => {
  Vue.directive(key, (directives as { [key: string]: DirectiveOptions })[key])
})

// Register global filter functions
// Object.keys(filters).forEach(key => {
//   Vue.filter(key, (filters as { [key: string]: Function })[key])
// })

Vue.config.productionTip = false
Vue.config.errorHandler = globalErrorHandler

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
